#ifndef EXPPARSER_H
#define EXPPARSER_H

#include "treenode.h"
#include <string>

enum Token_Type
{
    NUMBER = 0,
    NAME,
    LP,
    RP,
    OP
};

struct Token
{
    std::string     val_str;
    float           val_num;
    Token_Type      type;

    Token(Token_Type, std::string);
    Token(Token_Type, float);
};

class ExpParser
{
public:
    ExpParser();
    TreeNode*       parser(std::string exp);
private:
    std::string     str_exp;
    int             idx;
    float           readNum();
    std::string     readName();

    char            curChar(); //看一眼当前指向的字符
    char            getChar(); //获取当前指向的字符，并且后移指针
    char            nextChar();//看一眼下一个字符
    Token           nextToken();

};

#endif // EXPPARSER_H
